#!/usr/bin/python
# Import the CGI module
import cgi
import xmlrpcclient
import cgitb; cgitb.enable()


if __name__ == "__main__":
    #---------------------------------------------------------------------------
    #
    #--------------------------------------------------------------------------
    print "Content-Type: text/html\n\n"
    print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
    #-----------------------------------------------------------------------------
    #
    #----------------------------------------------------------------------------
    print '<html xmlns="http://www.w3.org/1999/xhtml"><head>'
    print ''
    print ''
    print '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>feedreader</title>'
    print ''
    print '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'
    print '<link href="http://localhost/shellcode.css" rel="stylesheet" type="text/css">'
    #---------------------------------------------------------------------------------
    print "<FORM METHOD=get ACTION=\"search.py\">"
    #----------------------------------------------------------------------------------
    print ''
    print ''
    print '<div id="body">'
    print '<table border="0" cellpadding="0" cellspacing="0" width="100%">'
    print '  <tbody><tr>'
    print '    <td width="5%">&nbsp;</td>'
    print '  </tr>'
    print '  <tr>'
    print '    <td height="1"></td>'
    print '    <td colspan="3" bgcolor="#ff0000"></td>'
    print '    <td></td>'
    print '  </tr>'
    print '  <tr>'
    print '    <td>&nbsp;</td>'
    print '    <td rowspan="3" align="right" bgcolor="#204444" height="100%" valign="top">'
    print '	          	<table border="0" cellpadding="0" cellspacing="3" width="100%">'
    print '      <tbody>'
    print ''
    print '	  <tr>'
    print '        <td>'
    print '		<div class="izquierda" align="right">'
    print '		 <a href="news-main.py" class="botonizquierda">MAIN</a> </div>'
    print '		</td>'
    print '      </tr>'
    print ''
    print '	  <tr>'
    print '        <td>'
    print '		<div class="izquierda" align="right">'
    print '		 <a href="feeds-main.py" class="botonizquierda">FEEDS</a> </div>'
    print '		</td>'
    print '      </tr>'
    print ''
    print '	  	  <tr>'
    print '        <td>'
    print '		<div class="izquierda" align="right">'
    print '		 <a href="search-main.py" class="botonizquierda">SEARCH</a> </div>'
    print '		</td>'
    print '      </tr>'
    print '	  <tr>'
    print '        <td bgcolor="#ff1111" height="1"></td>'
    print '      </tr>'
    print '	  </tbody></table>'
    print ''
    print ''
    print '	  </td>'
    print '    <td>&nbsp;</td>'
    print '    <td>&nbsp;</td>'
    print '  </tr>'
    print '  '
    print '  <tr>'
    print '    <td height="1"></td>'
    print '    <td></td>'
    print '    <td bgcolor="#330000"></td>'
    print '    <td></td>'
    print '  </tr>'
    print '  <tr>'
    print '    <td>&nbsp;</td>'
    print '    <td colspan="2">&nbsp;</td>'
    print '    <td>&nbsp;</td>'
    print '  </tr>'
    print '  <tr>'
    print '    <td>&nbsp;</td>'
    print '    <td>&nbsp;</td>'
    print '    <td>&nbsp;</td>'
    print '    <td>&nbsp;</td>'
    print '  </tr>'
    print '  <tr>'
    print '    <td>&nbsp;</td>'
    print '    <td colspan="3" align="right" valign="top">	  <table border="0" cellpadding="0" cellspacing="0" width="100%">'
    print '      <tbody><tr>'
    print '        <td id="content" width="20">&nbsp;</td>'
    print '        <td id="content" valign="top"><br>          '
    print ''
    print '<div class="datalist">'
    print ''
    #---------------------------------------------------------------------------------------------------
    print '<table border="0" cellpadding="1" cellspacing="1" width="100%">'
    print '<tbody>'
    print "categories that should be included in the search<br>"
    print '<input type="text" size="60" maxlength="100" name="intag"/><br>'
    print "categories that should  NOT be included in the search<br>"
    print '<input type="text" size="60" maxlength="100" name="outtag"/><br><br><br>'
    print "<INPUT TYPE = submit VALUE = \"search\">\n<br><br>"
    print 
    p = xmlrpcclient.printer()
    cat = p.getCategories()
    print 'the available categories are:<br>'
    l = cat.split(',')
    print '<table border = "6">'
    print '<tr>'
    for i in range(len(l)):
      if (i%2 == 0 and i != 0):
        print '</tr>'
        if (i != len(l)-1):      
          print '<tr>'
      print '<td>'+ l[i] +'</td>'
    print '</tr>'  
    print '<table/>'
    print '</tbody></table>'
    #print '<font size="5"><strong>' + cat + '<strong/><font/>'
    #---------------------------------------------------------------------------------------------------
    print ''
    print '</div>'
    
    print '		'
    print '</td>'
    print '        <td align="right" valign="top" width="20%">'
    print	'<table bgcolor="#101010" border="0" cellpadding="0" cellspacing="5" width="90%">'
    print '<tbody><tr>'
    print ' <td width="90%">'
    print ' <div class="izquierda" align="right">'
    print ' 	<a href="news-main.py" class="botonizquierda">Main</a>'
    print '  </div>'
    print '</td>'
    print '</tr>'
    print ''
    print ''
    print ''
    print ''
    print '<tr>'
    print ' <td width="90%">'
    print '  <div class="izquierda" align="right">'
    print '  	<a href="feeds-main.py" class="botonizquierda">Feeds</a>'
    print '  </div>'
    print ' </td>'
    print '</tr>'
    print ''
    print ''
    print ''
    print '<tr>'
    print ' <td width="90%">'
    print '  <div class="izquierda" align="right">'
    print '  	<a href="search-main.py" class="botonizquierda">Search</a>'
    print '  </div>'
    print ' </td>'
    print '</tr>'
    print ''
    print ''
    print '          <tr>'
    print '            <td bgcolor="#ff0000" height="1" width="90%"></td>'
    print '          </tr>'
    print '        </tbody></table>'
    print '		</td>'
    print '      </tr>'
    print '    </tbody></table></td>'
    print '    <td>&nbsp;</td>'
    print '  </tr>'
    print '  <tr>'
    print '    <td width="5%"></td>'
    print '    <td><img src="shellcodes_archivos/top_bg.png" height="3" width="193"></td>'
    print '    <td width="209"><img src="shellcodes_archivos/top_bg.png" height="3" width="209"></td>'
    print '    <td width="800"></td>'
    print '    <td width="5%"></td>'
    print '  </tr>'
    print '  </tbody></table>'
    #--------------------------------------------------------------------------------------------------------------
    #print '<input type="text" name="spin" value="'+ spiner +'"/>'
    #print '<button type="button" onclick="Spiner(1);">&uarr;</button>'
    #print '<button type="button" onclick="Spiner(-1);">&darr;</button>'
    #print "<INPUT TYPE=submit VALUE=\"submit\">\n"
    #print int(page)*int(spiner)
    #print int(spiner)*int(page)+int(spiner)
    #if(page!="0"):
    #    print '<a href=\"news-main.py?page=' + str(int(page)-1) + '&spin=' + spiner + "\">" + 'prev</a>'
    #if(int(spiner) == len(news)):
    #    print '<a href=\"news-main.py?page=' + str(int(page)+1) + '&spin='+ spiner + "\">" + 'next</a>'
    #---------------------------------------------------------------------------------------------------------------
    print ''
    print '<table border="0" cellpadding="0" cellspacing="0" width="100%">'
    print '      <tbody><tr>'
    print '        <td align="center" valign="top">&nbsp;</td>'
    print '        <td colspan="3" align="center" valign="top">&nbsp;</td>'
    print '        <td align="center" valign="top">&nbsp;</td>'
    print '      </tr>'
    print '      <tr>'
    print '          <td align="center" valign="top" width="5%"></td>'
    print '        <td align="center" valign="top"><img src="shellcodes_archivos/top_bg.png" height="3" width="193"></td>'
    print '        <td align="center" valign="top"></td>'
    print '        <td><img src="shellcodes_archivos/top_bg.png" height="3" width="209"></td>'
    print '        <td align="center" valign="top" width="5%"></td>'
    print '      </tr>'
    print ''
    print '  <tr>'
    print '    <td height="1"></td>'
    print '    <td colspan="3" bgcolor="#ff0000"></td>'
    print '    <td></td>'
    print '  </tr>'
    print '  <tr>'
    print '    <td>&nbsp;</td>'
    print '    <td>&nbsp;</td>'
    print '  </tr>'
    print '</tbody></table>'
    print '</div>'
    print '<br>'
    print ''
    print '</body></html>'
    
